#! /usr/bin/python
# -*- coding: cp1250 -*-

import glob, re, string, os
import faalib

inpfile_path_s   = './CSA_Ceske_aerolinie/data_01'
#inpfile_name_s   = '/*.txt'
inpfile_name_s   = '/14-06.txt'

o_file_fl = open('D01__14-06.out','w')

rows_length_h = {}
for infile_s in glob.glob(inpfile_path_s + inpfile_name_s):
    outline_s = ''
    line_cnt_n = 0
    for line_s in faalib.HugeFile(infile_s):
        line_cnt_n += 1
        #print len(line_s)
        if rows_length_h.get(len(line_s)):
            rows_length_h[len(line_s)] = rows_length_h[len(line_s)] + 1
        else:
            rows_length_h[len(line_s)] = 1
        if len(line_s) > 180:
            print str(infile_s) +'|' + \
                  str(line_cnt_n) +'|'+ \
                  line_s
        if len(line_s) >= 177 and line_s[65] =='-' and line_s[82] != '-' :
            o_file_fl.write(line_s)

print '%-8s -- %-8s' % ('rows_len', 'rows_cnt')
for llen_n in sorted(rows_length_h.keys(), reverse=True):
    print '%8s -- %8s' % (str(llen_n),
                            str(rows_length_h[llen_n]))

print '\n',inpfile_path_s + inpfile_name_s
o_file_fl.close()
